package com.zj.HJ;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class HJ36 {
    public static final char[] kkk = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String password = sc.nextLine();
        String word = sc.nextLine();

        System.out.println(getRes(word, password));
    }

    public static String getRes(String num, String password) {
        char[] dict = new char[26];
        Set<Character> set = new HashSet<>();
        int index = 0;
        for (int i = 0; i < password.length(); i++) {
            if (set.add(password.charAt(i))) {
                dict[index++] = password.charAt(i);
            }
        }
        for (int i = 0; i < kkk.length; i++) {
            if (set.add(kkk[i])) {
                dict[index++] = kkk[i];
            }
        }
        StringBuilder sb = new StringBuilder();
        String lowerNum = num.toLowerCase();
        for (int i = 0; i < lowerNum.length(); i++) {
            int site = lowerNum.charAt(i) - 'a';
            char newCh = dict[site];
            if (Character.isLowerCase(num.charAt(i))) {
                sb.append(newCh);
            } else {
                sb.append(Character.toUpperCase(newCh));
            }
        }
        return sb.toString();
    }


}
